<?php

namespace App\Model;


class GameFreeTask extends Model
{
    protected $table = 'game_free_task';

    public static function getValidFreeTask($taskType, $gameId)
    {
        try {
            $where = [
                ['task_type', '=', $taskType],
                ['game_id', '=', $gameId],
                ['status', '=', 1],
            ];
            $data = self::query()->where($where)->first();
            if (empty($data)) {
                return ['code' => 2, 'msg' => '未找到记录2！'];
            }
            return ['code' => 0, 'msg' => '获取成功！', 'data' => $data->toArray()];
        } catch (\Exception $e) {
            return ['code' => 1, 'msg' => $e->getMessage()];
        }
    }

}